package darknet.core.spec.friend;

import darknet.core.spec.exception.ImportingMyselfException;
import java.io.IOException;
import java.util.List;

/**
 * Specification of a Friend Manager.<br />
 * <br />
 * 
 * A friend manager "manage" the friend list.<br />
 * We can : 
 * <ul>
 * 	<li>Add a friend (thanks to his certificate)</li>
 * 	<li>Remove a friend</li>
 * 	<li>Export a friend's certificate</li>
 * </ul>
 * 
 * @author yoyo
 */
public interface FriendManager {

    /**
     * Get the list of all friend names.
     * @return 
     */
    List<String> get();
    
    /**
     * Get a friend.
     * 
     * @param friend The name of the friend.
     * @return The friend, or null if the friend doesn't exist.
     */
    Friend get(String friend);
    
    /**
     * Get a "friend" object, which represent ourself.
     * @return ourself
     */
    Friend getMe();
    
    /**
     * Add a new friend.<br />
     * <br />
     * 
     * If a previous friend with the same name already exist, 
     * he will be override.
     * 
     * @param toAdd The new friend to add.
     */
    void add(Friend toAdd) throws IOException, ImportingMyselfException;
    
    /**
     * Remove a friend.<br />
     * <br />
     * 
     * If the friend don't exist, nothing will be done.
     * 
     * @param toRemove The name of the friend to remove.
     */
    void remove(String toRemove) throws IOException;
    
}
